1. Field of the Invention
The present invention relates to an image processing method and apparatus, and to a program for realizing image processing functions in a computer, and more particularly, to quantization processing technology for a multiple-value image suitable for an inkjet recording apparatus or other image forming apparatus.
2. Description of the Related Art
In general, in an inkjet recording apparatus, a graded tonal image is formed by converting the light and shade of the image into an appropriate dot pattern, by using a half-toning method, such as error diffusion, dithering, or the like.
Here, a half-toning process relating to the prior art will be described. The most widely used techniques in half-toning are error diffusion and dithering.
Error diffusion is a method based on processing the errors generated when each dot (pixel) of a multiple-value image is quantized, and reflecting and diffusing these errors into the pixels surrounding the target pixel (the pixel being processed). The error may be distributed into the surrounding pixels in a uniform manner (without applying weighting), or it may be distributed by applying a weighting to the subsequently processed pixels, by means of a prescribed error diffusion matrix.
On the other hand, dithering is a method which sets a threshold value matrix comprising n×n threshold values, superimposes this threshold value matrix on the image, and then compares the shade level of each of the corresponding pixels with a threshold value. If the shade value of the input pixel is greater than the threshold value, then the pixel is taken to have a value of 1 and if it is smaller than the threshold value, then it is taken to have a value of 0; thereby the input image is binarized. When the processing of the n×n pixels has completed, the threshold value matrix is moved progressively to the position of the next n×n pixels, and the same processing is repeated. The threshold value matrix may also be known as a dithering matrix, or the like.
In general, the quality of the processed image varies greatly with the error diffusion matrix or threshold value matrix that is used. For example, if an error diffusion matrix or a threshold value matrix having a broad range of distribution is used, then it is possible to reproduce portions of the image having a smooth variation in density distribution, in a satisfactory manner, but in portions where the density distribution changes suddenly, the response declines and such satisfactory results cannot be obtained. Furthermore, a long processing time is required, since a large number of multiply and accumulation operations are made.
On the other hand, if an error diffusion matrix or threshold value matrix having a narrow distribution range is used, then image reproduction is good in portions of the image where there is a sudden change in density.
Japanese Patent Application Publication No. 8-214159 proposes a method in which a spatial frequency or a characteristic quantity corresponding to the spatial frequency is sampled for each pixel of an input image, a plurality of error diffusion matrices are prepared if using an error diffusion method, or a plurality of threshold value matrices are prepared if using a dithering method, and quantization processing is carried out by selecting the optimum error diffusion matrix or threshold value matrix in accordance with the characteristic quantity, thereby obtaining a good binary image which satisfies human visual perception characteristics.
More specifically, three threshold value matrices as illustrated in FIGS. 23A to 23C are prepared, and an optimum threshold value matrix is selected from these three threshold value matrices in accordance with the characteristic quantity (in this case, the spatial frequency) sampled from the target pixel.
FIG. 23A shows a threshold value matrix block 201, in which high-frequency threshold value matrices (H) 200 are arranged in four rows in the column direction (vertical direction or y direction) and in four rows in the row direction (horizontal direction or x direction). FIG. 23B shows a threshold value matrix block 203, in which medium-frequency threshold value matrices (M) 202 are arranged in two rows in the column direction and two rows in the row direction, and FIG. 23C shows a low-frequency threshold value matrix (L) 204. The high-frequency threshold value matrices 200 have a narrow error distribution range (in other words, few threshold values), and the low-frequency threshold value matrix 204 has a broad error distribution range (in other words, a large number of threshold values). The medium-frequency threshold value matrices 204 are situated at an intermediate point between the high-frequency threshold value matrices 200 and the low-frequency threshold value matrices 204.
The high-frequency threshold value matrices 200 shown in FIG. 23A each have a size of m×m (where m is a natural number); the medium-frequency threshold value matrices 202 shown in FIG. 23B each have a size of (2×m)×(2×m) (i.e., a size four times greater than that of the high-frequency threshold value matrices 200), and the low-frequency threshold value matrix 204 shown in FIG. 23C has a size of (4×m)×(4×m) (i.e., a size sixteen times greater than that of the high-frequency threshold value matrices 200).
In an image in which a plurality of pixels are arranged in the column direction and the row direction, it is determined which spatial frequency range the image of certain pixels under examination (a pixel block containing the pixels under examination) belongs to, from the density values of the pixels (pixel block) under examination, and one of the threshold value matrices suited to that spatial frequency range is selected and set.
The threshold value for a pixel under examination is determined from the threshold value matrix thus set, and the density value of the pixel under examination is compared with the determined threshold value. If the density value of the pixel under examination is equal to or greater than the threshold value, then the value of the pixel under examination is taken to be 1, and if the density value of the pixel under examination is less than the threshold value, then the value of the pixel under examination is taken to be 0. The similar processing is carried out successively for each pixel or each pixel block, and a dot arrangement for a binary image is thus established.
With regard to the size of the three threshold value matrices disclosed in Japanese Patent Application Publication No. 8-214159, the size of the largest matrix, namely, the low-frequency threshold value matrix 204, is taken as the basic unit, and the size of each high-frequency threshold value matrix 200 is set to 1/16 of the size of the low-frequency threshold value matrix 204, while the size of the medium-frequency threshold value matrix 202 is set to ¼ of the size of the low-frequency threshold value matrix 204. Quantization processing is carried out by combining these matrices in a suitable manner.
However, since the calculation becomes complicated if threshold value matrices of different sizes are used in this way, the other threshold value matrices are adapted to the size of the low-frequency threshold value matrix 204 by forming a threshold value matrix block 203 comprising an arrangement of four medium-frequency threshold value matrices 202, and a threshold value matrix block 201 comprising an arrangement of 16 high-frequency threshold value matrices 200, and hence the threshold value corresponding to a pixel under examination can be calculated by using a 4×4 size threshold value matrix at all times.
In the example of an image 410 shown in FIG. 24, the image is divided into six regions 412 to 422, and an optimum threshold value matrix is-established for each region. The low-frequency threshold value matrix 204 is selected for regions 412, 414 and 416, the medium-frequency threshold value matrices 202 (threshold value matrix block 203) are selected for regions 418 and 420, and the high-frequency threshold value matrices 200 (threshold value matrix block 201) are selected for region 422.
If the image is quantized by changing between different threshold value matrices within one image in this way, then a problem arises in that the processing may not necessarily appropriate for an image in which the spatial frequency characteristics change within a region, for instance, if there is a sudden change in density within region 412.